package com.example.h2

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.h2.ui.theme.H2Theme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            H2Theme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Box(
                        modifier = Modifier
                            .fillMaxSize()
                            .padding(innerPadding)
                    ) {
                        Image(
                            painter = painterResource(id = R.drawable.hua),
                            contentDescription = "Background",
                            modifier = Modifier
                                .matchParentSize(),
                            alpha = 0.5f
                        )
                        
                        Column(
                            verticalArrangement = Arrangement.Center,
                            horizontalAlignment = Alignment.CenterHorizontally,
                            modifier = Modifier
                                .fillMaxSize()
                        ) {
                            Spacer(modifier = Modifier.height(200.dp))

                            Image(
                                painter = painterResource(id = R.drawable.mao),
                                contentDescription = "Avatar",
                                modifier = Modifier
                                    .padding(vertical = 20.dp)
                                    .size(150.dp),
                                alpha = 0.5f
                            )

                            Text(
                                text = "hanyu",
                                textAlign = TextAlign.Center,
                                fontSize = 50.sp,
                                lineHeight = 50.sp,
                                modifier = Modifier.padding(vertical = 10.dp)
                            )

                            Text(
                                text = "Android Studio",
                                fontSize = 20.sp,
                                lineHeight = 30.sp,
                                modifier = Modifier.padding(vertical = 10.dp)
                            )

                            Spacer(modifier = Modifier.weight(1f))

                            Column(
                                verticalArrangement = Arrangement.Bottom,
                                horizontalAlignment = Alignment.CenterHorizontally,
                                modifier = Modifier.fillMaxWidth()
                            ) {
                                Row(
                                    horizontalArrangement = Arrangement.Center,
                                    verticalAlignment = Alignment.CenterVertically,
                                    modifier = Modifier.padding(vertical = 10.dp)
                                ) {
                                    Image(
                                        painter = painterResource(id = R.drawable.dianhua),
                                        contentDescription = null,
                                        modifier = Modifier
                                            .height(30.dp)
                                            .width(30.dp)
                                    )
                                    Text(
                                        text = "+123456789",
                                        textAlign = TextAlign.Center,
                                        fontSize = 20.sp,
                                        lineHeight = 20.sp,
                                        modifier = Modifier.padding(start = 8.dp)
                                    )
                                }

                                Row(
                                    horizontalArrangement = Arrangement.Center,
                                    verticalAlignment = Alignment.CenterVertically,
                                    modifier = Modifier.padding(vertical = 10.dp)
                                ) {
                                    Image(
                                        painter = painterResource(id = R.drawable.dizhi),
                                        contentDescription = null,
                                        modifier = Modifier
                                            .height(30.dp)
                                            .width(30.dp)
                                    )
                                    Text(
                                        text = "+@AndroidDev",
                                        textAlign = TextAlign.Center,
                                        fontSize = 20.sp,
                                        lineHeight = 20.sp,
                                        modifier = Modifier.padding(start = 8.dp)
                                    )
                                }

                                Row(
                                    horizontalArrangement = Arrangement.Center,
                                    verticalAlignment = Alignment.CenterVertically,
                                    modifier = Modifier.padding(vertical = 10.dp)
                                ) {
                                    Image(
                                        painter = painterResource(id = R.drawable.youjian),
                                        contentDescription = null,
                                        modifier = Modifier
                                            .height(30.dp)
                                            .width(30.dp)
                                    )
                                    Text(
                                        text = "+12346@qq.com",
                                        textAlign = TextAlign.Center,
                                        fontSize = 20.sp,
                                        lineHeight = 20.sp,
                                        modifier = Modifier.padding(start = 8.dp)
                                    )
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    H2Theme {
        Box(
            modifier = Modifier
                .fillMaxSize()
                .padding(16.dp)
        ) {
            Image(
                painter = painterResource(id = R.drawable.hua),
                contentDescription = "Background",
                modifier = Modifier
                    .matchParentSize(),
                alpha = 0.5f
            )
            
            Column(
                verticalArrangement = Arrangement.Center,
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier
                    .fillMaxSize()
            ) {
                Spacer(modifier = Modifier.height(200.dp))

                Image(
                    painter = painterResource(id = R.drawable.mao),
                    contentDescription = "Avatar",
                    modifier = Modifier
                        .padding(vertical = 20.dp)
                        .size(150.dp)
                )

                Text(
                    text = "hanyu",
                    textAlign = TextAlign.Center,
                    fontSize = 50.sp,
                    lineHeight = 50.sp,
                    modifier = Modifier.padding(vertical = 10.dp)
                )

                Text(
                    text = "Android Studio",
                    fontSize = 20.sp,
                    lineHeight = 30.sp,
                    modifier = Modifier.padding(vertical = 10.dp)
                )

                Spacer(modifier = Modifier.weight(1f))

                Column(
                    verticalArrangement = Arrangement.Bottom,
                    horizontalAlignment = Alignment.CenterHorizontally,
                    modifier = Modifier.fillMaxWidth()
                ) {
                    Row(
                        horizontalArrangement = Arrangement.Center,
                        verticalAlignment = Alignment.CenterVertically,
                        modifier = Modifier.padding(vertical = 10.dp)
                    ) {
                        Image(
                            painter = painterResource(id = R.drawable.dianhua),
                            contentDescription = null,
                            modifier = Modifier
                                .height(30.dp)
                                .width(30.dp)
                        )
                        Text(
                            text = "+123456789",
                            textAlign = TextAlign.Center,
                            fontSize = 20.sp,
                            lineHeight = 20.sp,
                            modifier = Modifier.padding(start = 8.dp)
                        )
                    }

                    Row(
                        horizontalArrangement = Arrangement.Center,
                        verticalAlignment = Alignment.CenterVertically,
                        modifier = Modifier.padding(vertical = 10.dp)
                    ) {
                        Image(
                            painter = painterResource(id = R.drawable.dizhi),
                            contentDescription = null,
                            modifier = Modifier
                                .height(30.dp)
                                .width(30.dp)
                        )
                        Text(
                            text = "+@AndroidDev",
                            textAlign = TextAlign.Center,
                            fontSize = 20.sp,
                            lineHeight = 20.sp,
                            modifier = Modifier.padding(start = 8.dp)
                        )
                    }

                    Row(
                        horizontalArrangement = Arrangement.Center,
                        verticalAlignment = Alignment.CenterVertically,
                        modifier = Modifier.padding(vertical = 10.dp)
                    ) {
                        Image(
                            painter = painterResource(id = R.drawable.youjian),
                            contentDescription = null,
                            modifier = Modifier
                                .height(30.dp)
                                .width(30.dp)
                        )
                        Text(
                            text = "+12346@qq.com",
                            textAlign = TextAlign.Center,
                            fontSize = 20.sp,
                            lineHeight = 20.sp,
                            modifier = Modifier.padding(start = 8.dp)
                        )
                    }
                }
            }
        }
    }
}